package client;

import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import nwpu.cn.grpc.api.RPCAddRequest;
import nwpu.cn.grpc.api.RPCAddResponse;
import nwpu.cn.grpc.api.RPCAddServiceGrpc;

public class GRPCClient {
    private static final String host="localhost";
    private static final int serverport=9999;
    public static void main(String[] args) throws Exception{
        ManagedChannel managedChannel = ManagedChannelBuilder.forAddress(host, serverport).usePlaintext().build();
       try {

           RPCAddServiceGrpc.RPCAddServiceBlockingStub rpcAddService = RPCAddServiceGrpc.newBlockingStub(managedChannel);
           RPCAddRequest rpcAddRequest = RPCAddRequest.newBuilder().setFirst("1").setSecond("2").build();
           RPCAddResponse rpcAddResponse = rpcAddService.getAdd(rpcAddRequest);
           System.out.println(rpcAddResponse.getResult());
       }finally {
           managedChannel.shutdown();
       }
    }
}
